package org.jetlinks.pro.logging;

import org.hswebframework.ezorm.core.param.QueryParam;
import org.jetlinks.pro.elastic.search.service.ElasticSearchService;
import org.jetlinks.pro.logging.access.SerializableAccessLog;
import org.jetlinks.pro.logging.event.handler.LoggerIndexProvider;
import org.jetlinks.pro.logging.system.SerializableSystemLog;
import org.mockito.Mockito;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * 输入描述.
 *
 * @author zhangji
 * @version 1.11 2021/12/29
 */
public class ElasticSearchServiceUtils {
    public static List<SerializableSystemLog> SYSTEM_LOG_LIST = Arrays.asList(
        SerializableSystemLog.builder()
            .id("1")
            .mavenModule("device")
            .name("设备")
            .threadName("thread-device-1")
            .context(new HashMap<>())
            .build(),
        SerializableSystemLog.builder()
            .id("2")
            .mavenModule("device")
            .name("设备")
            .threadName("thread-device-2")
            .context(new HashMap<>())
            .build(),
        SerializableSystemLog.builder()
            .id("3")
            .mavenModule("device")
            .name("设备")
            .threadName("thread-device-3")
            .context(new HashMap<>())
            .build()
    );

    public static List<SerializableAccessLog> ACCESS_LOG_LIST = new ArrayList<>();

    static {
        Map<String, Object> param = new HashMap<>();
        param.put("username", "test");
        Map<String, String> httpHeader = new HashMap<>();
        httpHeader.put("content-type", "text");
        for (int i = 1; i < 4; i++) {
            SerializableAccessLog accessLog = new SerializableAccessLog();
            accessLog.setAction("login system");
            accessLog.setDescribe("登录-" + i);
            accessLog.setMethod("login");
            accessLog.setTarget("TestTarget");
            accessLog.setParameters(param);
            accessLog.setHttpHeaders(httpHeader);
            accessLog.setHttpMethod("POST");
            accessLog.setRequestTime(System.currentTimeMillis());
            accessLog.setResponseTime(System.currentTimeMillis());
            ACCESS_LOG_LIST.add(accessLog);
        }
    }
}
